package com.wh.stock.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wh.stock.pojo.StockLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wh.stock.dao.StockLogMapper;
import com.wh.stock.service.IStockLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wh.stock.dto.StockLogQueryDto;

import java.util.List;

/**
 * 业务实现类
 */
@Service
public class StockLogServiceImpl extends ServiceImpl<StockLogMapper,StockLog> implements IStockLogService {

    @Autowired
    private StockLogMapper stockLogMapper;

    @Override
    public IPage<StockLog> findByPage(StockLogQueryDto stockLogQueryDto){
        //1.创建查询条件
        QueryWrapper<StockLog> qw = new QueryWrapper<>();
        //qw.like("xxx",stockLogQueryDto.getXxx());
        //qw.or();
        //qw.like("xxx",stockLogQueryDto.getXxx());
        //2.组件分页数据
        IPage<StockLog> page = new Page<>(stockLogQueryDto.getCurrentPage(), stockLogQueryDto.getPageSize());
        page.setRecords(stockLogMapper.findByPage(page,qw));
        page.setTotal(stockLogMapper.selectCount(qw));
        //3.返回
        return page;
    }

    @Override
    public List<StockLog> findStockLog(Long procId) {
      return stockLogMapper.findStockLog(procId);
    }
}
